#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
mt19937_64 rnd(time(0));
const int N = 2e5+5;
ull val[N];
bool ve[N];
bool vis[N];
int U[N],V[N],n;
vector<int>e[N];
int m;
ull bs[64];
void dfs(int u,int fe)
{
    ull sum = 0;
    vis[u] = 1;
    //cout<<"!"<<u<<" "<<fe<<"\n";
    for(auto E:e[u]) if(E != fe)
    {
        int v = U[E] ^ V[E] ^ u;
        if(!vis[v]) ve[E] = 1,dfs(v,E);
        else if(!ve[E])
        {
            val[E] = rnd();
            //cout<<"!"<<E<<" "<<val[E];
            //cerr<<"!"<<E<<"\n";
            ve[E] = 1;
        }
        sum ^= val[E];
    }
    val[fe] = sum;
}
int main()
{
    //system("fc graph.out graph2.ans");
    freopen("graph.in","r",stdin);
    freopen("graph.out","w",stdout);
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n>>m;
    for(int i = 1;i <= m;i++)
    {
        cin>>U[i]>>V[i];
        e[U[i]].push_back(i);
        e[V[i]].push_back(i);
    }
    dfs(1,0);
    int Q;cin>>Q;
    //for(int i = 1;i <= n;i++) if(!vis[i]) cerr<<"FUCK\n";
    //for(int i = 1;i <= m;i++)
    //{
    //    if(vis[U[i]] ^ vis[V[i]])
    //    {
    //        cerr<<"fuck\n";
    //        cerr<<i<<"\n";
    //        cerr<<ve[i]<<"\n";
    //    }
    //}
    //cout<<"==\n";
    //for(int i = 1;i <= m;i++) cout<<val[i]<<" "<<ve[i]<<"\n"; 
    //cout<<"==\n";
    while(Q--)
    {
        int k;cin>>k;
        int rem = k;
        memset(bs,0,sizeof(bs));
        while(k--)
        {
            ull x;cin>>x;
            x = val[x];
            //cout<<x<<"\n";
            for(int i = 63;i > 0;i--)
                if(x & 1ull << i)
                {
                    if(!bs[i])
                    {
                        bs[i] = x;
                        rem--;
                    }
                    x ^= bs[i];
                }
        }
        //cout<<rem<<"\n";
        if(rem) cout<<"NO\n";
        else cout<<"YES\n";
    }
    return 0;
}